package com.qf.shop.system;

import java.util.*;

public class Demo {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        while (true) {
            count(scanner.next());
        }
    }

    static Map<String, Integer> urlMap = new HashMap<String, Integer>();

    public static void count(String input) {

        int maxSumPage = 5000;
        int maxCurrentPage = 65535;
        int currentSumPage = 0;
        try {
            int top = Integer.parseInt(input);
            if (top <= 10) {
                Map<Integer, String> urlOrderMap = new TreeMap<>();
                for (Map.Entry<String, Integer> entry : urlMap.entrySet()) {
                    urlOrderMap.put(entry.getValue(), entry.getKey());
                }
                int index = 0;
                for (Map.Entry<Integer, String> entry : urlOrderMap.entrySet()) {
                    if (index > top) {
                        return;
                    }
                    index++;
                    System.out.println(entry.getValue() + ":" + entry.getKey());
                }
            }
            // 输入数字
        } catch (Exception e) {

            // 输入url
            if (input.getBytes().length <= 127) {

                int index = input.indexOf(",");
                if (index != -1) {
                    String[] split = input.split(",");
                    StringBuilder builder = new StringBuilder();
                    for (int i = 0; i < split.length; i++) {
                        String str = split[i];
                        if (builder.length() > 0 && builder.toString().endsWith("/")) {
                            if (str.startsWith("/")) {
                                builder.append(str.substring(1, str.length()));
                            } else {
                                builder.append(str);
                            }
                        } else {
                            if (str.startsWith("/")) {
                                builder.append(str);
                            } else {
                                builder.append("/").append(str);
                            }
                        }
                    }
                    input = builder.toString();
                }

                Integer num = urlMap.get(input);
                if (num != null && num > maxCurrentPage) {
                    System.out.println("当前url查过限制");
                    return;
                }
                if (urlMap.keySet().size() > maxSumPage) {
                    System.out.println("网页总访问量");
                    return;
                }
                if (num == null) {
                    urlMap.put(input, 1);
                } else {
                    urlMap.put(input, ++num);
                }
                System.out.println(input + ":" + urlMap.get(input));
            }
        }
    }
}
